const http=require('http');
let client=http.request({
    host:'www.baidu.com',
    port:80,
    pathname:'/s?wd=abc&rsv_spt=1&rsv_iqid=0xfb30fc1a00000f03&issp=1&f=8&rsv_bp=0&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_enter=1&rsv_sug3=3&rsv_sug1=3&rsv_sug7=100&rsv_sug2=0&inputT=887&rsv_sug4=887',
    headers:{
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36'
        //  默认的是 ie解析    设置后强制chrome解析
    }
},(res)=>{
    let str='';
    res.on('data',data=>{
        str+=data;
    })
    res.on('end',()=>{
        console.log(str)
    })
    res.on('error',(err)=>{

        console.log('请求失败')
    })



})
client.end();
//  将console.log 输出到 文件里面   node server.js > bd.html